package com.sc.nft.admin.controller;

import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.dto.IdRequest;
import com.sc.nft.dto.MerchantDaoAddDTO;
import com.sc.nft.feign.MerchantDaoClient;
import com.sc.nft.sup.Result;
import com.sc.nft.vo.MerchantDaoGetByIdVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * dao拥有的产品列表(MerchantDao)表控制层
 *
 * @author wwc
 * @since 2023-03-28 13:50:32
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("admin/merchantDao")
@Api(tags = "dao拥有的产品列表")
public class MerchantDaoController {

    private final MerchantDaoClient merchantDaoClient;

    @PostMapping(value = "/addOrOverwrite", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "给dao新增或覆盖产品", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result addOrOverwrite(@RequestBody @Validated MerchantDaoAddDTO merchantDaoAddDTO) {
        return merchantDaoClient.addOrOverwrite(merchantDaoAddDTO);
    }

    @PostMapping(value = "/getDaoById", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "根据id获取dao拥有的产品列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<MerchantDaoGetByIdVO> getDaoById(@RequestBody @Validated IdRequest idRequest) {
        return merchantDaoClient.getDaoById(idRequest);
    }

}
